<?php

if ( !class_exists( "BME_object" ) ) {
require_once("Base.php");

class BME_object extends BME_base {
	
	var $id;		// int	ID on Lcl-DB.
	var $version;		// int	Version of object.
	var $source;		// str	Source of the object (primary or some protocol).
	
	/**
	 * bme_object new bme_object([mix id[, int version]]);
	 * @param mix id (optional): The ID on Lcl-DB (int), or the ID.version (str or float).
	 * @param int version (optional): The version of the object.
	 * @return bme_object (object).
	 */
	function __construct($id=NULL,$version=NULL) {
		parent::__constructor();
		if(!is_null($id)) $this->load($id,$version);
	}
	/**
	 * void _parseid(mix &id, int &version);
	 * @param mix id: id(int) or id.version(str or float).
	 * @param int version.
	 */
	function _parseId(&$id,&$version){
		if(!is_null($version)){
			$id=(int)$id;
			$version=(int)$version;
		}else{
			if(ereg("^([0-9]+)[\.,]([0-9]+)$",(string)$id,$reg)){
				$id=(int)$reg[1];
				$version=(int)$reg[2];
			}else{
				$id=(int)$id;
				$version=NULL;
			}
		}
	}
	/**
	 * str getid(void);
	 * @return str: Id w. version.
	 */
	function getId(){
		assert('isset($this->id)');
		return $this->id.".".$this->version;
	}
	/**
	 * int getaccesion(void);
	 * @return int: Accession number (ID wo. version).
	 */
	function getAccession(){
		assert('isset($this->id)');
		return $this->id;
	}
	/**
	 * int getversion(void);
	 * @return int: Version.
	 */
	function getVersion(){
		assert('isset($this->id)');
		return $this->version;
	}
	/**
	 * str getsource(void);
	 * @return str: source.
	 */
	function getSource(){
		assert('isset($this->id)');
		return $this->source;
	}
}

}


?>
